package mumethod;

import java.util.List;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import muobject.*;

public class SchoolReportDataSource implements JRDataSource {
	private List<Object> datas = null ;
	private int loop = -1 ; 
	
	public SchoolReportDataSource(List<Object> data){
		this.datas = data;
	}
	
	public Object getFieldValue(JRField field) throws JRException {
		School temp = (School)this.datas.get(loop);
		Object rs = "" ;
		/*if("sid".equals(field.getName())){  
			rs = temp.getSid();   
		}else if("name".equals(field.getName())){
			rs = temp.getName();
		}else if("location".equals(field.getName())){
			rs = temp.getLocation();
		}*/
		temp = null ;  
		return rs;
	}
	
	public boolean next() throws JRException {
		loop ++ ;
		if(loop >= datas.size()){
			return false;
		}
		else{   
			return true ;
		}
	}
	
	public void finalized(){
		datas = null ;  
	}
}
